﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Ntalk
{
    public partial class Page1 : PhoneApplicationPage, IPageReceiver
    {
        public Page1()
        {
            InitializeComponent();
        }

        private void listBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        public void receiveMessage(String dest, String message)
        {
            var TextBox1 = new TextBox();
            TextBox1.Text = dest + " :\n" + message;
            TextBox1.UseLayoutRounding = true;
            TextBox1.TextWrapping = TextWrapping.Wrap;
            TextBox1.IsReadOnly = true;
            TextBox1.Width = 450;
            messageList.Items.Add(TextBox1);
            messageList.ScrollIntoView(messageList.Items.Last());
        }

        public void receiveData(String data)
        {
        }

        private void EnvoyerButton_Click(object sender, RoutedEventArgs e)
        {
            ((App)Application.Current).sendMessage("user_cmd msg_user "+DestinataireBox.Text+" msg "+MessageBox.Text);
        }
    }
}